package com.xdwanj.smartcity;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;
import com.xdwanj.smartcity.data.config.Configs;
import com.xdwanj.smartcity.data.repository.impl.HomeRepository;
import com.xdwanj.smartcity.data.repository.impl.UploadRepository;
import com.xdwanj.smartcity.data.repository.impl.UserRepository;

public class App extends Application {

    public static Context context;
    public static SharedPreferences sp;
    public static RequestQueue queue;
    public static Gson gson;

    @Override
    public void onCreate() {
        super.onCreate();

        context = this;
        queue = Volley.newRequestQueue(this);
        sp = this.getSharedPreferences("data", MODE_PRIVATE);
        gson = new Gson();

        initRepo();
        initData();
    }

    private void initData() {
        Configs.TOKEN = sp.getString("token", "");
    }

    private void initRepo() {
        HomeRepository.init();
        UserRepository.init();
        UploadRepository.init();
    }

}
